<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>极简宠物伙伴2</title>
    <style>
        body {
            background-color: #f8f9fa;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            color: #495057;
            text-align: center;
            margin: 0;
            padding: 20px;
        }
        h1 {
            color: #4dabf7;
            font-weight: 300;
            margin-bottom: 30px;
        }
        .pet-container {
            margin: 40px auto;
            width: 200px;
            height: 200px;
            background-color: #ffffff;
            border-radius: 16px;
            display: flex;
            justify-content: center;
            align-items: center;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
            transition: transform 0.3s;
        }
        .pet-container:hover {
            transform: translateY(-5px);
        }
        .pet {
            font-size: 5em;
            color: #4dabf7;
        }
        .action-buttons {
            display: flex;
            justify-content: center;
            flex-wrap: wrap;
            gap: 10px;
            margin: 20px;
        }
        .btn {
            background-color: #e9ecef;
            color: #495057;
            border: none;
            padding: 12px 24px;
            border-radius: 8px;
            cursor: pointer;
            font-size: 0.9em;
            transition: all 0.2s;
        }
        .btn:hover {
            background-color: #4dabf7;
            color: white;
            transform: scale(1.05);
        }
        .status-bar {
            margin: 20px auto;
            max-width: 300px;
            background-color: #e9ecef;
            padding: 15px;
            border-radius: 8px;
        }
        .status-item {
            display: flex;
            justify-content: space-between;
            margin: 8px 0;
        }
        .progress-bar {
            height: 8px;
            background-color: #dee2e6;
            border-radius: 4px;
            margin-top: 5px;
            overflow: hidden;
        }
        .progress {
            height: 100%;
            background-color: #4dabf7;
            width: 30%; /* 初始值 */
            transition: width 0.5s;
        }
    </style>
</head>
<body>
<h1>0626第1版代码</h1>
<h1>🐾 极简宠物伙伴</h1>

<div class="status-bar">
    <div class="status-item">
        <span>💖 心情</span>
        <span id="mood">平静</span>
    </div>
    <div class="progress-bar">
        <div class="progress" id="mood-progress"></div>
    </div>

    <div class="status-item">
        <span>🍎 能量</span>
        <span id="energy">70%</span>
    </div>
    <div class="progress-bar">
        <div class="progress" id="energy-progress" style="width: 70%;"></div>
    </div>
</div>

<div class="pet-container">
    <div class="pet" id="pet">🐱</div>
</div>

<div class="action-buttons">
    <button class="btn" onclick="feedPet()">喂食</button>
    <button class="btn" onclick="playWithPet()">玩耍</button>
    <button class="btn" onclick="cleanPet()">清洁</button>
</div>

<script>
    let mood = 50; // 0-100
    let energy = 70; // 0-100

    function updateStatus() {
        document.getElementById('mood').textContent = mood > 70 ? "开心" : mood > 30 ? "平静" : "难过";
        document.getElementById('mood-progress').style.width = mood + "%";

        document.getElementById('energy').textContent = energy + "%";
        document.getElementById('energy-progress').style.width = energy + "%";
    }

    function feedPet() {
        energy = Math.min(100, energy + 20);
        mood = Math.min(100, mood + 10);
        document.getElementById('pet').textContent = "😋";
        setTimeout(() => {
            document.getElementById('pet').textContent = "🐱";
        }, 800);
        updateStatus();
    }

    function playWithPet() {
        mood = Math.min(100, mood + 25);
        energy = Math.max(0, energy - 10);
        document.getElementById('pet').textContent = "🎉";
        setTimeout(() => {
            document.getElementById('pet').textContent = "🐱";
        }, 1000);
        updateStatus();
    }

    function cleanPet() {
        mood = Math.min(100, mood + 15);
        document.getElementById('pet').textContent = "🛁";
        setTimeout(() => {
            document.getElementById('pet').textContent = "🐱";
        }, 1000);
        updateStatus();
    }

    // 模拟能量随时间下降
    setInterval(() => {
        energy = Math.max(0, energy - 1);
        updateStatus();
    }, 5000); // 每5秒减少1点能量

    // 初始状态
    updateStatus();
</script>
</body>
</html>